package app.model.global
{	
	import app.service.event.SharedObjectServiceEvent;
	
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	
	import org.robotlegs.mvcs.Actor;
	import app.model.vo.AlertVO;
	import app.model.event.ModelEvent;

	
	public class ApplicationModel extends Actor
	{
		public static const SHARED_OBJECT_NAME:String = "main/userdata";

		public var currentAlert:AlertVO;

		
		//path to config xml file
		public var configXML:String;
		
		// configENV provides an environment key: 0 = ide, 1 = localhost, 2 = otherhost, 3 = staging, 4 = production
		public var configENV:String;
		
		//config xml data 
		public var configDATA:XML;
		

		public function getFlashPath():String
		{
			var result:String;
			if(configDATA)
			{			
				result = configDATA.environment[configENV].flashPath[0].toString(); 
			}
			return result;
		}
		
/*
		public function getServiceURL(api:String):String
		{
			var result:String;
			if(configDATA)
			{
				var shop:XML = configDATA.service[0] as XML;
				var serviceBase1:String = shop.proxy[0].toString() + shop.serviceBase1[0].toString();
				var serviceBase2:String = shop.proxy[0].toString() + shop.serviceBase2[0].toString();
				switch(api)
				{
					case ShopEvent.GET_STORES:
						result = serviceBase2 + shop.getStores[0].toString();
						break;
					case ShopEvent.GET_PROMOTIONS:
						result = serviceBase2 + shop.getPromotions[0].toString();
						break;
					case ShopEvent.GET_PROMOTION_PAGES:
						result = serviceBase2 + shop.getPromotionPages[0].toString();
						break;
					case ShopEvent.GET_PROMOTION_PAGE_LISTINGS:
						result = serviceBase1 + shop.getPromotionPageListings[0].toString();
						break;
					case ShopEvent.GET_BRANDS:
						result = serviceBase2 + shop.getBrands[0].toString();
						break;
					case ShopEvent.GET_BRAND_LISTINGS:
						result = serviceBase2 + shop.getBrandListings[0].toString();
						break;
					case ShopEvent.GET_CATEGORIES:
						result = serviceBase2 + shop.getCategories[0].toString();
						break;
					case ShopEvent.GET_CATEGORY_LISTINGS:
						result = serviceBase2 + shop.getCategoryListings[0].toString();
						break;
					
				}
				
			}
			return result;
		}*/
		
		public function vectorToArray(v:*):Array
		{
				var n:int = v.length; var a:Array = new Array();
				for(var i:int = 0; i < n; i++) a[i] = v[i];
				return a;
		}
	
		/*
		public function isDebug():Boolean{
			var debug:Boolean = false;
			CONFIG::debugging{
				debug = true;
			}
			return debug;
		}
		*/


	}
}